package logic

import (
	"context"
	"video-hub/model/mysql"
	"video-hub/videorpc/internal/svc"
	"video-hub/videorpc/videorpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type VideoAndUserAndTopicLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewVideoAndUserAndTopicLogic(ctx context.Context, svcCtx *svc.ServiceContext) *VideoAndUserAndTopicLogic {
	return &VideoAndUserAndTopicLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *VideoAndUserAndTopicLogic) VideoAndUserAndTopic(in *videorpc.VideoAndUserAndTopicRequest) (*videorpc.VideoAndUserAndTopicResponse, error) {
	// todo: add your logic here and delete this line
	var video videorpc.VideoAndUserAndTopicResponse
	video, err := mysql.VideoAndUserAndTopic(mysql.DB, in.VideoId)
	if err != nil {
		return nil, err
	}
	return &videorpc.VideoAndUserAndTopicResponse{
		VideoTitle: video.VideoTitle,
		VideoIntro: video.VideoIntro,
		Num:        video.Num,
		NickName:   video.NickName,
		Url:        video.Url,
		TopicName:  video.TopicName,
	}, nil
}
